package auto.test.util;

import java.io.File;

import org.apache.commons.mail.EmailAttachment;
import org.apache.commons.mail.EmailException;
import org.apache.commons.mail.HtmlEmail;

public class SendFileMail {
	public void SendMail2() {
		  HtmlEmail mail=new HtmlEmail();
		  GetConfigPath getconfigpath=new GetConfigPath();
			ProUtil pro=new ProUtil(getconfigpath.GetconfigPath());
			 mail.setHostName("smtp.163.com");
			 mail.setAuthentication("553187951@163.com","YKHDHWFBBICOKGPR");
			 try {
				mail.setFrom("553187951@163.com");
				 mail.addTo("553187951@qq.com");
				 mail.setSubject("动态更新通知");
				 mail.setCharset("UTF-8");
				 mail.send();
			} catch (EmailException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		  
	  }

	public void SendMail() {
		HtmlEmail mail=new HtmlEmail();
		GetConfigPath getconfigpath=new GetConfigPath();
		ProUtil pro=new ProUtil(getconfigpath.GetconfigPath());
		mail.setHostName("");
		mail.setAuthentication(pro.GetPro("emailfrom"),pro.GetPro("emailfrompws"));
		try {
			mail.setFrom(pro.GetPro("emailfrom"));
			mail.addTo(pro.GetPro("emailto"));
			mail.setSubject("autoemail");
			mail.setCharset("UTF-8");
			mail.setHtmlMsg("<a herf=\"\">测试报告");
			EmailAttachment emailAttachment=new EmailAttachment();
			emailAttachment.setPath(System.getProperty("user.dir")+File.separator+pro.GetPro("SendEmailimgpath"));
			emailAttachment.setName("report.html");
			emailAttachment.setDescription(EmailAttachment.ATTACHMENT);
			mail.attach(emailAttachment);
			mail.send();
		} catch (EmailException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}
	public static void main(String[] args) {
		SendFileMail sendFileMail=new SendFileMail();
		sendFileMail.SendMail2();
	}
}
